<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta name="screen-orientation" content="portrait">
    <meta name="x5-orientation" content="portrait">
    <title>提前结算开通</title>
    <link rel="stylesheet" href="../../styles/h5/reset.min.css"/>
    <link rel="stylesheet" href="../../styles/h5/errortankuang.css"/>
    <!--以上为公共css样式-->
    <link rel="stylesheet" href="../../styles/h5/index.css"/>

    <script charset="utf-8" type="text/javascript" src="../../scripts/h5/jquery-1.9.1.min.js"></script>
    <script charset="utf-8" type="text/javascript" src="../../scripts/h5/jquery.modal.js"></script>
    <!--以上为公共js文件-->
</head>
<body>
<div class="zz-header">
    免费开通提前结算
</div>
<div class="zz-list">
    <ul>
        <li>
            <span class="zz-left">产品名称</span
            ><span class="zz-right zz-set-product-name"></span>
        </li>
        <li>
            <span class="zz-left">到账银行卡</span
            ><span class="zz-right zz-set-bank-name"></span
        ><span class="zz-right zz-set-bank-card"></span>
        </li>
        <li>
            <span class="zz-left">手机号</span
            ><span class="zz-right zz-set-bank-phone"></span>
        </li>
        <li class="zz-position">
            <span class="zz-left">验证码</span
            ><input class="zz-code-num zz-verification-code" type="text" placeholder="请输入验证码" maxlength="6"
                    pattern="[0-9]*"/>
            <input class="zz-code" type="button" value="获取验证码"/>
        </li>
    </ul>

</div>
<div class="zz-read zz-paddingLeft">
    <span class="zz-check"></span>
    <span>同意</span>
    <a href="http://m.soopay.net/c/static/oyhyybdv">《联动优势提前结算服务协议》</a>
</div>
<!-- <input class="footer" type="button" style="display:none" value="立即免费开通"> -->
</body>
<script charset="utf-8" type="text/javascript" src="../../scripts/h5/utils.js"></script>
<script charset="utf-8" type="text/javascript">
    var queryURLParameter = utils.queryURLParameter();
    var merId = queryURLParameter.merId;
    //初始化接口
    $.ajax({
        url: utils.ajaxUrl()+"h5/advanceSettle/initialize",
        data: {
            merId: merId
        },
        async: false,
        type: 'get',
        success: function (res) {
       		//var res = JSON.parse(res);
        	console.log(res);
            if (res && res.retCode == '0000') {
                $(".zz-set-product-name").html(res.productName);
                $(".zz-set-bank-name").html(res.bankName);
                $(".zz-set-bank-phone").html(res.bankMobileId);
                $(".zz-set-bank-card").html("(" + utils.cutOut(res.bankAccount) + ")");

            } else {
                utils.newModalPrompt(res.retMsg);
                $(".footer").attr("disabled", "true");
            }
        }
    });
</script>
<script charset="utf-8" type="text/javascript" src="../../scripts/h5/index.js"></script>

<script charset="utf-8" type="text/javascript">
    //点击获取验证码
    
    $code.click(function () {
        var that = $(this);
        
        $.ajax({
         	url: utils.ajaxUrl() + "h5/sign/send",
         	async: false,
         	data: {
         		storeId: merId
         	},
         	type: 'get',
         	success: function (res) {
         		var res = JSON.parse(res);
         		if (res && res.retCode == '0000') {
         			//alert(res.verifyCode);
         			utils.time(that);
         			//utils.effectivePhone(bankMobileId, that, utils.time, that);
         		} else {
         			utils.newModalPrompt(res.retMsg,that);
         		}
         	}
         });
    });

    function check() {
        if ($check.hasClass("zz-not-check")) {
            $check.removeClass("zz-not-check");
        } else {
            $check.addClass("zz-not-check");
        }
    }

    $check.click(function () {
        check();
    });

    $footer.click(function () {
        var verifyCode = $verification_code.val();
    
        // 判断验证码
        if (!utils.effectiveNum(verifyCode, $footer)) {
            return false
        }

        // 判断勾是否被选中
        if ($check.hasClass("zz-not-check")) {
            utils.newModalPrompt('请您阅读并同意服务协议。',$footer);
            return false;
        }

        utils.newModalAnimationShow("加载中");

        $.ajax({
            url: utils.ajaxUrl() + "h5/advanceSettle/dredge",
            data: {
                merId: merId,
                verifyCode: verifyCode
            },
            async: false,
            type: 'get',
            success: function (res) {
                console.log(res);
                if (res && res.retCode == "0000") {
                    utils.newModalAnimationHide();
                    window.location.href = "../../html/h5/advancePayApply.html?merId="+merId;
                } else {
                    utils.newModalAnimationHide(0);
                    utils.newModalPrompt(res.retMsg,$footer);
                }
            }
        });
    })
</script>
</html>